<template>
  <div class="pagestyle">
    <list_controller
      ref="zujianname"
      :options="state.optionsList"
      pageName=""
      @tabChange="tabChange"
      :tabName="state.tabNameData"
      @yinyong="yinyong1"
    >
      <template v-slot:opraCurdBtnAll>
        <el-button class="btn" type="primary" link @click="addBtn('mul')">
          <el-icon style="margin-right: 2px">
            <svg-icon
              class-name="search-icon"
              icon-class="addtotal"
            /> </el-icon
          >新增
        </el-button>
        <el-button class="btn" type="primary" link @click="deleteBtn('mul')">
          <el-icon> <DeleteFilled /> </el-icon>删除
        </el-button>
      </template>
      <template v-slot:expandFixed="row">
        <div class="expand-wrapper" v-if="row.row.row.subIndexes">
          <vxe-table border :data="row.row.row.subIndexes">
            <vxe-column
              v-for="(item, index) in state.optionsList.subtableheads"
              :field="item.field"
              :title="item.title"
              :params="{ name: item.name }"
              :width="item.width ? item.width : ''"
              :key="index"
            >
              <template #default="{ row }">
                <!-- <span v-if="item.title === '【高】量程上/下限'">
              {{ row['highRangeUp']+'/'+row['highRangeDown'] }}</span>
              <span v-if="item.title === '【低】量程上/下限'">
                {{ row['lowRangeUp']+'/'+row['lowRangeDown'] }}</span>
             <span v-else>{{ row[item.field] }}</span> -->
                <span>{{ row[item.field] }}</span>
              </template>
            </vxe-column>
          </vxe-table>
        </div>
        <!-- <div class="expand-wrapper" v-if="row.row.row.sensorAddChildList">
                  <vxe-table border :data="row.row.row.sensorAddChildList">
                      <vxe-column v-for="(item,index) in state.optionsList.subtableheads" :field="item.field"
                          :title="item.title" :params="{name:item.name}" :width="item.width?item.width:''"
                          :key="index">
                      </vxe-column>
                  </vxe-table>
              </div> -->
      </template>
      <template v-slot:opraCurdBtn1="row">
        <span>
          <el-button
            type="primary"
            link
            size="small"
            @click="editBtn(row.row.row)"
            >编辑</el-button
          >
          <el-button
            type="primary"
            :disabled="row.row.row.refStatus == '已引用'"
            link
            size="small"
            @click="deleteBtn(row.row.row)"
            >删除</el-button
          >
        </span>
      </template>
    </list_controller>
    <!-- 新增弹框模拟量 -->
    <teleport to="body">
      <vxe-modal
        esc-closable
        destroy-on-close
        :lock-view="false"
        :width="1200"
        :height="auto"
        v-model="state.addModal"
        resize
        :mask="true"
      >
        <template #title>
          <div class="w100 h100 fsc mask_title">{{ state.modalTitle }}</div>
        </template>
        <template #default>
          <div class="form_box">
            <el-form
              ref="formRef"
              :model="state.formData"
              :rules="state.rules"
              label-position="top"
            >
              <div v-if="state.tabName == 'simulate'">
                <el-row :gutter="20">
                  <el-col :span="7">
                    <el-form-item label="名称" prop="indexName">
                      <el-input
                        clearable
                        v-model="state.formData.indexName"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="7">
                    <el-form-item label="主索引" prop="indexNumber">
                      <el-input
                        clearable
                        oninput="value=value.replace(/[^\d]/g,'')"
                        v-model.number="state.formData.indexNumber"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="7">
                    <el-form-item label="子索引" prop="hasSubIndex">
                      <el-switch
                        v-model="state.formData.hasSubIndex"
                        @change="hasChildChange"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <!-- v-if="!state.formData.hasChild" -->
                    <el-form-item label="单位" prop="">
                      <el-input
                        clearable
                        v-model="state.formData.unit"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <!-- v-if="!state.formData.hasChild" -->
                    <el-form-item label="高量程">
                      <div class="inputrange fbc">
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="state.formData.highRangeUpperLimit"
                          placeholder="请输入上限"
                        >
                        </el-input>
                        <span>-</span>
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="state.formData.highRangeLowerLimit"
                          placeholder="请输入下限"
                        >
                        </el-input>
                      </div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <!--  v-if="!state.formData.hasChild" -->
                    <el-form-item label="低量程">
                      <div class="inputrange fbc">
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="state.formData.lowRangeUpperLimit"
                          placeholder="请输入上限"
                        >
                        </el-input>
                        <span>-</span>
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="state.formData.lowRangeLowerLimit"
                          placeholder="请输入下限"
                        >
                        </el-input>
                      </div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24" v-if="state.formData.hasSubIndex">
                    <p class="mask_sub_title fbc">
                      <span>
                        <svg-icon
                          class-name="search-icon"
                          icon-class="dot"
                        />子索引</span
                      >
                      <el-button type="primary" @click="childAddClick" link>
                        <Plus />新增</el-button
                      >
                    </p>
                  </el-col>
                  <el-row
                    v-if="state.formData.hasSubIndex"
                    :gutter="20"
                    style="padding: 0 10px; display: flex; align-items: center"
                    v-for="(item, index) in state.formData.subIndexes"
                    :key="index"
                  >
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].indexNumber`"
                        :rules="{
                          required: true,
                          message: '请输入编号',
                          trigger: 'blur',
                        }" -->
                      <el-form-item label="编号">
                        <el-input
                          style="width: 160px"
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model="item.indexNumber"
                          @change="
                            checkIndex(
                              item.indexNumber,
                              index,
                              state.formData.subIndexes
                            )
                          "
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].indexName`"
                        :rules="{
                          required: true,
                          message: '请输入名称',
                          trigger: 'blur',
                        }" -->
                      <el-form-item label="名称">
                        <el-input
                          clearable
                          style="width: 160px"
                          v-model="item.indexName"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].unit`"
                        :rules="{
                          required: true,
                          message: '请输入单位',
                          trigger: 'blur',
                        }" -->
                      <el-form-item label="单位">
                        <el-input
                          style="width: 160px"
                          clearable
                          v-model="item.unit"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item label="低量程">
                        <div class="inputrange fbc">
                          <el-input
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.lowRangeUpperLimit"
                            placeholder="请输入上限"
                          >
                          </el-input>
                          <span>-</span>
                          <el-input
                            :min="item.lowRangeLowerLimit"
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.lowRangeLowerLimit"
                            placeholder="请输入下限"
                          >
                          </el-input>
                        </div>
                      </el-form-item>
                    </el-col>
                    <el-col :span="5">
                      <el-form-item label="高量程">
                        <div class="inputrange fbc">
                          <el-input
                            :min="item.lowScaleUp"
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.highRangeUpperLimit"
                            placeholder="请输入上限"
                          >
                          </el-input>
                          <span>-</span>
                          <el-input
                            :min="item.highRangeLowerLimit"
                            clearable
                            oninput="value=value.replace(/[^\d.]/g,'')"
                            v-model.number="item.highRangeLowerLimit"
                            placeholder="请输入下限"
                          >
                          </el-input>
                        </div>
                      </el-form-item>
                    </el-col>
                    <el-col :span="2" v-if="state.editId">
                      <el-form-item label="引用状态">
                        <el-tag
                          type="success"
                          v-if="item.quoteStatus == 1"
                          @click="
                            yinyong2(
                              state.formData.primaryIndexId,
                              item.childIndexId
                            )
                          "
                          >{{
                            item.quoteStatus == 0 ? "未引用" : "已引用"
                          }}</el-tag
                        >
                        <el-tag v-else>{{
                          item.quoteStatus == 0 ? "未引用" : "已引用"
                        }}</el-tag>
                      </el-form-item>
                    </el-col>
                    <el-col :span="1">
                      <!-- <img
                        v-if="item.quoteStatus == '0'"
                        src="@/assets/icons/svg/删除.svg"
                        alt=""
                      /> -->
                      <svg-icon
                        v-if="
                          item.quoteStatus !== 1 &&
                          state.formData.subIndexes.length > 1
                        "
                        class-name="search-icon"
                        icon-class="delkong"
                        @click="delchaildIndexClick(item, index)"
                      />
                    </el-col>
                  </el-row>
                </el-row>
              </div>
              <div v-if="state.tabName == 'switch'">
                <el-row :gutter="20">
                  <el-col :span="6">
                    <el-form-item label="名称" prop="indexName">
                      <el-input
                        clearable
                        v-model="state.formData.indexName"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="主索引" prop="indexNumber">
                      <el-input
                        clearable
                        oninput="value=value.replace(/[^\d]/g,'')"
                        v-model="state.formData.indexNumber"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="子索引" prop="hasSubIndex">
                      <el-switch
                        v-model="state.formData.hasSubIndex"
                        @click="hasChildChange"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="开关量模式" prop="modeId">
                      <!-- modeName -->
                      <el-select
                        clearable
                        filterable
                        v-model="state.formData.modeId"
                        placeholder="请选择"
                      >
                        <el-option
                          v-for="item in state.switchModelList"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="常态逻辑" prop="normalLogicId">
                      <!-- normalLogicName -->
                      <el-select
                        clearable
                        filterable
                        v-model="state.formData.normalLogicId"
                        placeholder="请选择"
                      >
                        <el-option
                          v-for="item in state.normalLogicList"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="高电平显示" prop="highLevelDisplay">
                      <el-input
                        clearable
                        v-model="state.formData.highLevelDisplay"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="低电平显示" prop="lowLevelDisplay">
                      <el-input
                        clearable
                        v-model="state.formData.lowLevelDisplay"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24" v-if="state.formData.hasSubIndex">
                    <p class="mask_sub_title fbc">
                      <span>
                        <svg-icon
                          class-name="search-icon"
                          icon-class="dot"
                        />子索引</span
                      >
                      <el-button type="primary" @click="childAddClick" link>
                        <Plus />新增</el-button
                      >
                    </p>
                  </el-col>
                  <el-row
                    v-if="state.formData.hasSubIndex"
                    :gutter="20"
                    style="padding: 0 10px; display: flex; align-items: center"
                    v-for="(item, index) in state.formData.subIndexes"
                    :key="index"
                  >
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].indexNumber`"
                        :rules="{
                          required: true,
                          message: '请输入编号',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="编号"
                       
                      >
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="item.indexNumber"
                          @change="
                            checkIndex(
                              item.number,
                              index,
                              state.formData.subIndexes
                            )
                          "
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].indexName`"
                        :rules="{
                          required: true,
                          message: '请输入名称',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="名称"
                        
                      >
                        <el-input
                          clearable
                          v-model="item.indexName"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].modeId`"
                        :rules="{
                          required: true,
                          message: '请输入开关量模式',
                          trigger: 'change',
                        }" -->
                      <el-form-item
                        label="开关量模式"
                        
                      >
                        <el-select
                          clearable
                          filterable
                          v-model="item.modeId"
                          placeholder="请选择"
                        >
                          <el-option
                            v-for="item in state.switchModelList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].normalLogicId`"
                        :rules="{
                          required: true,
                          message: '请输入常态逻辑',
                          trigger: 'change',
                        }" -->
                      <el-form-item
                        label="常态逻辑"
                        
                      >
                        <el-select
                          clearable
                          filterable
                          v-model="item.normalLogicId"
                          placeholder="请选择"
                        >
                          <el-option
                            v-for="item in state.normalLogicList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].highLevelDisplay`"
                        :rules="{
                          required: true,
                          message: '请输入高电平显示',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="高电平显示"
                        
                      >
                        <el-input
                          clearable
                          v-model="item.highLevelDisplay"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].lowLevelDisplay`"
                        :rules="{
                          required: true,
                          message: '请输入低电平显示',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="低电平显示"
                       
                      >
                        <el-input
                          clearable
                          v-model="item.lowLevelDisplay"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="2" v-if="state.editId">
                      <el-form-item label="引用状态" prop="">
                        <el-tag
                          type="success"
                          v-if="item.quoteStatus == '0'"
                          @click="
                            yinyong2(
                              state.formData.primaryIndexId,
                              item.childIndexId
                            )
                          "
                          >{{
                            item.quoteStatus == "0" ? "已引用" : "未引用"
                          }}</el-tag
                        >
                        <el-tag v-else>{{
                          item.quoteStatus == "0" ? "已引用" : "未引用"
                        }}</el-tag>
                      </el-form-item>
                    </el-col>
                    <el-col :span="1">
                      <!-- <img
                        v-if="item.quoteStatus == '0'"
                        src="@/assets/icons/svg/删除.svg"
                        alt=""
                      /> -->
                      <svg-icon
                        v-if="
                          item.quoteStatus !== '0' &&
                          state.formData.subIndexes.length > 1
                        "
                        class-name="search-icon"
                        icon-class="delkong"
                        @click="delchaildIndexClick(item, index)"
                      />
                    </el-col>
                  </el-row>
                </el-row>
              </div>
              <div v-if="state.tabName == 'accumulate'">
                <el-row :gutter="20">
                  <el-col :span="6">
                    <el-form-item label="名称" prop="indexName">
                      <el-input
                        clearable
                        v-model="state.formData.indexName"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="累计周期" prop="cumulatePeriodId">
                    <!-- cumulatePeriodName -->
                      <el-select
                        clearable
                        filterable
                        v-model="state.formData.cumulatePeriodId"
                        placeholder="请选择"
                        style="width: 100%"
                      >
                        <el-option
                          v-for="item in state.cumulatePeriodList"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="主索引" prop="indexNumber">
                      <el-input
                        clearable
                        oninput="value=value.replace(/[^\d]/g,'')"
                        v-model="state.formData.indexNumber"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="子索引" prop="">
                      <el-switch
                        v-model="state.formData.hasSubIndex"
                        @click="hasChildChange"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="单位" prop="unit">
                      <el-input
                        clearable
                        oninput="value=value.replace(/[^\d]/g,'')"
                        v-model="state.formData.unit"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="累计模式" prop="cumulateModeId">
                      <!-- cumulateModeName -->
                      <el-select
                        clearable
                        filterable
                        v-model="state.formData.cumulateModeId"
                        placeholder="请选择"
                        style="width: 100%"
                      >
                        <el-option
                          v-for="item in state.cumulateModeList"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="起始值" prop="initialValue">
                      <el-input
                        clearable
                        v-model="state.formData.initialValue"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="变化值" prop="changeValue">
                      <el-input
                        clearable
                        v-model="state.formData.changeValue"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="上限值" prop="upperLimitValue">
                      <el-input
                        clearable
                        v-model="state.formData.upperLimitValue"
                        placeholder="请输入"
                      >
                      </el-input>
                    </el-form-item>
                  </el-col>
                  <el-col :span="24" v-if="state.formData.hasSubIndex">
                    <p class="mask_sub_title fbc">
                      <span>
                        <svg-icon
                          class-name="search-icon"
                          icon-class="dot"
                        />子索引</span
                      >
                      <el-button type="primary" @click="childAddClick" link>
                        <Plus />新增</el-button
                      >
                    </p>
                  </el-col>
                  <el-row
                    v-if="state.formData.hasSubIndex"
                    :gutter="20"
                    style="padding: 0 10px; display: flex; align-items: center"
                    v-for="(item, index) in state.formData.subIndexes"
                    :key="index"
                  >
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].indexNumber`"
                        :rules="{
                          required: true,
                          message: '请输入编号',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="编号"
                       
                      >
                        <el-input
                          oninput="value=value.replace(/[^\d.]/g,'')"
                          clearable
                          v-model.number="item.indexNumber"
                          @change="
                            checkIndex(
                              item.indexNumber,
                              index,
                              state.formData.subIndexes
                            )
                          "
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].indexName`"
                        :rules="{
                          required: true,
                          message: '请输入名称',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="名称"
                        
                      >
                        <el-input
                          clearable
                          v-model="item.indexName	"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].unit`"
                        :rules="{
                          required: true,
                          message: '请输入单位',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="单位"
             
                      >
                        <el-input
                          clearable
                          v-model="item.unit"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <!-- <el-col :span="3">
                    <el-form-item label="累计周期" prop="cumulatePeriod">
                      <el-select
                        clearable
                        filterable
                        v-model="state.formData.cumulatePeriod"
                        placeholder="请选择"
                        style="width: 100%"
                      >
                        <el-option
                          v-for="item in state.cumulatePeriodList"
                          :key="item.value"
                          :label="item.label"
                          :value="item.value"
                        >
                        </el-option>
                      </el-select>
                    </el-form-item>
                  </el-col> -->
                    <el-col :span="3">
                      <!-- cumulateModeName -->
                      <!-- :prop="`subIndexes[${index}].cumulateModeId`"
                        :rules="{
                          required: true,
                          message: '请输入累计模式',
                          trigger: 'change',
                        }" -->
                      <el-form-item
                        label="累计模式"
                       
                      >
                        <el-select
                          clearable
                          filterable
                          v-model="item.cumulateModeId"
                          placeholder="请选择"
                        >
                          <el-option
                            v-for="item in state.cumulateModeList"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                          >
                          </el-option>
                        </el-select>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].initialValue`"
                        :rules="{
                          required: true,
                          message: '请输入起始值',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="起始值"
              
                      >
                        <el-input
                          clearable
                          v-model="item.initialValue"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].changeValue`"
                        :rules="{
                          required: true,
                          message: '请输入变化值',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="变化值"
                        
                      >
                        <el-input
                          clearable
                          v-model="item.changeValue"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="3">
                      <!-- :prop="`subIndexes[${index}].upperLimitValue`"
                        :rules="{
                          required: true,
                          message: '请输入上限值',
                          trigger: 'blur',
                        }" -->
                      <el-form-item
                        label="上限值"
             
                      >
                        <el-input
                          clearable
                          v-model="item.upperLimitValue"
                          placeholder="请输入"
                        >
                        </el-input>
                      </el-form-item>
                    </el-col>
                    <el-col :span="2" v-if="state.editId">
                      <el-form-item label="引用状态" prop="">
                        <el-tag
                          type="success"
                          v-if="item.quoteStatus == '0'"
                          @click="
                            yinyong2(
                              state.formData.primaryIndexId,
                              item.childIndexId
                            )
                          "
                          >{{
                            item.quoteStatus == "0" ? "已引用" : "未引用"
                          }}</el-tag
                        >
                        <el-tag v-else>{{
                          item.quoteStatus == "0" ? "已引用" : "未引用"
                        }}</el-tag>
                      </el-form-item>
                    </el-col>
                    <el-col :span="1">
                      <!-- <img
                        v-if="item.quoteStatus == '0'"
                        src="@/assets/icons/svg/删除.svg"
                        alt=""
                      /> -->
                      <svg-icon
                        v-if="
                          item.quoteStatus !== '0' &&
                          state.formData.subIndexes.length > 1
                        "
                        class-name="search-icon"
                        icon-class="delkong"
                        @click="delchaildIndexClick(item, index)"
                      />
                    </el-col>
                  </el-row>
                </el-row>
              </div>
            </el-form>
            <div class="form_footer">
              <el-button @click="cancel">取消</el-button>
              <el-button type="primary" @click="submitForm"> 确定 </el-button>
            </div>
          </div>
        </template>
      </vxe-modal>
    </teleport>
  </div>
</template>
<script setup>
import list_controller from "@/components/commonCom/list_controller";
import { useRouter } from "vue-router";
import { computed, onBeforeUpdate, onMounted, reactive } from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
import { table_headers } from "@/components/commonCom/table_headers";
import axios from "@/utils/request";
import {
  getchildIndex,
  getsensorName,
  getunit,
  fileupload,
  getchildIndexadd,
  getsensorNameadd,
} from "@/api/config";
import usePagesStore from "@/store/modules/pages";
const { proxy } = getCurrentInstance();
const store = usePagesStore();
const router = useRouter();
const upload = ref();
const upload1 = ref();
const upload2 = ref();
const validatePass = (rule, value, callback) => {
  let reg = new RegExp(/^\+?[1-9][0-9]*$/);
  if (value == "") {
    return;
  }
  let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    validParamType = state.options.validParam;
  } else if (state.tabName == "switch") {
    validParamType = state.options1.validParam;
  } else if (state.tabName == "add") {
    validParamType = state.options2.validParam;
  }
  if (state.editId) {
    axios
      .get(validParamType, {
        params: { type: 1, value: value, id: state.editId },
      })
      .then((res) => {
        if (res.code == 200) {
          state.repeat = false;
          callback();
          if (!reg.test(value)) return callback(new Error("请输入整数"));
        }
      })
      .catch((res) => {
        state.repeat = true;
        return callback(new Error("主索引不能重复"));
      });
  } else {
    axios
      .get(validParamType, { params: { type: 1, value: value } })
      .then((res) => {
        console.log(res);
        if (res.code == 200) {
          state.repeat = false;
          callback();
          if (!reg.test(value)) return callback(new Error("请输入整数"));
        }
      })
      .catch((res) => {
        state.repeat = true;
        return callback(new Error("主索引不能重复"));
      });
  }
  // let reg = new RegExp(/^\+?[1-9][0-9]*$/);
  // if(state.repeat){
  //     return callback(new Error("主索引不能重复"));
  // }else{
  //     callback();
  //     if (!reg.test(value))
  //      return callback(new Error("请输入整数"));
  // }
};
const validatePass2 = (rule, value, callback) => {
  let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    validParamType = state.options.validParam;
  } else if (state.tabName == "switch") {
    validParamType = state.options1.validParam;
  } else if (state.tabName == "add") {
    validParamType = state.options2.validParam;
  }
  if (state.editId) {
    axios
      .get(validParamType, {
        params: { type: 0, value: value, id: state.editId },
      })
      .then((res) => {
        if (res.code == 200) {
          state.repeat2 = false;
          callback();
        }
      })
      .catch((res) => {
        state.repeat2 = true;
        return callback(new Error("名称不能重复"));
      });
  } else {
    axios
      .get(validParamType, { params: { type: 0, value: value } })
      .then((res) => {
        if (res.code == 200) {
          state.repeat2 = false;
          callback();
        }
      })
      .catch((res) => {
        state.repeat2 = true;
        return callback(new Error("名称不能重复"));
      });
  }
};
const validatePass3 = (rule, value, callback) => {
  if (value == "") {
    return;
  }
  if (value == state.formData.lowShow) {
    callback(new Error("高低电平显示不能重复"));
  } else {
    callback();
  }
};
const validatePass4 = (rule, value, callback) => {
  if (value == "") {
    return;
  }
  if (value == state.formData.highShow) {
    callback(new Error("高低电平显示不能重复"));
  } else {
    callback();
  }
};
components: {
  list_controller;
}
let state = reactive({
  nowranDis: false,
  noshangwranDis: false,
  tabNameData: "模拟量",
  optionsList: {},
  options: {
    isShowCaozuo: true,
    expandFixed: true,
    tabList: [
      {
        tabIndex: 1,
        name: "模拟量",
      },
      {
        tabIndex: 2,
        name: "开关量",
      },
      {
        tabIndex: 3,
        name: "累计量",
      },
    ],
    tableheads: computed(() => table_headers.analogPrimaryIndex),
    subtableheads: computed(() => table_headers.analogSubIndex),
    queryList: {
      dropdownUrl: "",
      querys: [
        {
          field: "primaryIndexName",
          title: "主索引名称",
          type: "input",
          binddata: "",
        },
        {
          field: "primaryIndexNumber",
          title: "主索引编号",
          type: "input",
          binddata: "",
          options: [],
        },
        // {
        //   field: "subIndex",
        //   title: "子索引",
        //   type: "select",
        //   binddata: "",
        //   options: [],
        // },
      ],
      queryMap: new Map([
        ["sensorTypeId", "safety_pointType"],
        ["deviceTypeId", "safety_deviceType"],
        ["alarmTypeId", "alarmType"],
      ]),
    },
    dataUrl: "/gas/base/feature/analog/list", //出厂特性模拟量列表
    delUrl: "/gas/base/feature/analog/delete",
    addUrl: "/gas/base/feature/analog/save",
    //   descUrl: '/sensor/simulate/detailSpecial?primaryIndexId=',
    editUrl: "/gas/base/feature/analog/save",
    //   validParam:'/sensor/simulate/validParam',
  },
  options1: {
    isShowCaozuo: true,
    expandFixed: true,
    tabList: [
      {
        tabIndex: 1,
        name: "模拟量",
      },
      {
        tabIndex: 2,
        name: "开关量",
      },
      {
        tabIndex: 3,
        name: "累计量",
      },
    ],
    tableheads: computed(() => table_headers.switchPrimaryIndex),
    subtableheads: computed(() => table_headers.switchSubIndex),
    queryList: {
      dropdownUrl: "",
      querys: [
        {
          field: "primaryIndexName",
          title: "主索引名称",
          type: "input",
          binddata: "",
        },
        {
          field: "primaryIndexNumber",
          title: "主索引编号",
          type: "input",
          binddata: "",
          options: [],
        },
        // {
        //   field: "subIndex",
        //   title: "子索引",
        //   type: "select",
        //   binddata: "",
        //   options: [],
        // },
      ],
      queryMap: new Map([
        ["sensorTypeId", "safety_pointType"],
        ["deviceTypeId", "safety_deviceType"],
        ["alarmTypeId", "alarmType"],
      ]),
    },
    dataUrl: "/gas/base/feature/switch/list", //出厂特性开关量列表
    delUrl: "/gas/base/feature/switch/delete",
    addUrl: "/gas/base/feature/switch/save",
    //   descUrl: '/sensor/switch/detailSpecial?primaryIndexId=',
    editUrl: "/gas/base/feature/switch/save",
    //   validParam:'/sensor/switch/validParam',
  },
  options2: {
    isShowCaozuo: true,
    expandFixed: true,
    tabList: [
      {
        tabIndex: 1,
        name: "模拟量",
      },
      {
        tabIndex: 2,
        name: "开关量",
      },
      {
        tabIndex: 3,
        name: "累计量",
      },
    ],
    tableheads: computed(() => table_headers.cumulatePrimaryIndex),
    subtableheads: computed(() => table_headers.cumulateSubIndex),
    queryList: {
      dropdownUrl: "",
      querys: [
        {
          field: "primaryIndexName",
          title: "主索引名称",
          type: "input",
          binddata: "",
        },
        {
          field: "primaryIndexNumber",
          title: "主索引编号",
          type: "input",
          binddata: "",
          options: [],
        },
        // {
        //   field: "subIndex",
        //   title: "子索引",
        //   type: "select",
        //   binddata: "",
        //   options: [],
        // },
      ],
      queryMap: new Map([
        ["sensorTypeId", "safety_pointType"],
        ["deviceTypeId", "safety_deviceType"],
        ["alarmTypeId", "alarmType"],
      ]),
    },
    dataUrl: "/gas/base/feature/cumulate/list",
    delUrl: "/gas/base/feature/cumulate/delete",
    addUrl: "/gas/base/feature/cumulate/save",
    editUrl: "/gas/base/feature/cumulate/save",
  },
  // 表单
  tabName: "simulate", //simulate,switch
  addModal: false,
  modalTitle: "新增模拟量",
  formRef: null,
  formData: {},
  locations: [{}],
  rules: {
    deviceName: [
      {
        required: true,
        message: "请输入名称",
        trigger: "blur",
      },
      //   {
      //     validator: validatePass2,
      //     trigger: "blur",
      //   },
    ],
    primaryIndex: [
      {
        required: true,
        message: "请输入主索引",
        trigger: "blur",
      },
    ],
    subIndex: [
      {
        required: true,
        message: "请选择子索引",
        trigger: "change",
      },
    ],
    // unit: [
    //   {
    //     required: true,
    //     message: "请输入单位",
    //     trigger: "blur",
    //   },
    // ],
    number: [
      {
        required: true,
        message: "请输入编号",
        trigger: "blur",
      },
    ],
    subIndexName: [
      {
        required: true,
        message: "请输入名称",
        trigger: "blur",
      },
    ],
    subIndexUnit: [
      {
        required: true,
        message: "请输入单位",
      },
    ],
    //开关量
    switchMode: [
      {
        required: true,
        message: "请选择开关量模式",
        trigger: "change",
      },
    ],
    normalLogic: [
      {
        required: true,
        message: "请选择常态逻辑",
        trigger: "change",
      },
    ],
    highLevel: [
      {
        required: true,
        message: "请输入高电平显示",
        trigger: "blur",
      },
    ],
    lowLevel: [
      {
        required: true,
        message: "请输入低电平显示",
        trigger: "blur",
      },
    ],
    // primaryIndexId: [
    //   {
    //     required: true,
    //     message: "请输入主索引",
    //     trigger: "blur",
    //   },
    //   {
    //     validator: validatePass,
    //     trigger: "blur",
    //   },
    // ],
  },
  editId: undefined,
  resetTypeList: [
    {
      code: 0,
      name: "个数",
    },
    {
      code: 1,
      name: "小时",
    },
    {
      code: 2,
      name: "班",
    },
    {
      code: 3,
      name: "天",
    },
    {
      code: 4,
      name: "月",
    },
    {
      code: 5,
      name: "年",
    },
  ],
  // 下拉数据
  switchModelList: [], //开关量模式
  normalLogicList: [], //常态逻辑
  cumulatePeriodList: [], //累计周期
  cumulateModeList:[], //累计模式
  orderTypeList: [
    {
      code: "0",
      name: "递增",
    },
    {
      code: "1",
      name: "递减",
    },
  ],
  // addeditShow: false,
  repeat: false,
  repeat2: false,
});
// 主索引跳转
const yinyong1 = (row) => {
  console.log(row);
  //   router.push({
  //     path: "/cspz/basicConfig/deviceChara_analog",
  //     query: { primaryIndexId: row.primaryIndexId, tabName: state.tabName },
  //   });
};
// 子索引跳转
const yinyong2 = (pId, id) => {
  //   router.push({
  //     path: "/cspz/basicConfig/deviceChara_analog",
  //     query: { primaryIndexId: pId, childIndexId: id, tabName: state.tabName },
  //   });
};

// 新增按钮
function addBtn(row) {
  if (state.tabName == "simulate") {
    state.modalTitle = "新增模拟量";
  } else if (state.tabName == "switch") {
    state.modalTitle = "新增开关量";
  } else if (state.tabName == "accumulate") {
    state.modalTitle = "新增累计量";
  }
  state.addModal = true;
  state.formData = {};
  state.editId = undefined;
  // state.addeditShow = true;
}
// 编辑按钮
function editBtn(row) {
  console.log(row, "row");
  state.formData = row;
  state.editId = row.featureId;
  if (state.tabName == "simulate") {
    state.modalTitle = "编辑模拟量";
  } else if (state.tabName == "switch") {
    state.modalTitle = "编辑开关量";
  } else if (state.tabName == "accumulate") {
    state.modalTitle = "编辑累计量";
  }
  state.addModal = true;
}

function deleteBtn(row) {
  console.log(row, "row");
  let delUrltype = state.options.delUrl;
  if (state.tabName == "simulate") {
    delUrltype = state.options.delUrl;
  } else if (state.tabName == "switch") {
    delUrltype = state.options1.delUrl;
  } else if (state.tabName == "accumulate") {
    delUrltype = state.options2.delUrl;
  }
  let ids = [];
  if (row != "mul") {
    ids = [row.featureId];
  } else {
    if (store.records.length > 0) {
      ids = store.records.map((item) => {
        return item.featureId;
      });
    } else {
      proxy.$modal.msgSuccess("请先勾选所要删除数据!");
    }
  }
  if (ids.length > 0) {
    ElMessageBox.confirm("确定要删除吗?", "温馨提示", {
      confirmButtonText: "确定",
      cancelButtonText: "取消",
      type: "warning",
    })
      .then(() => {
        axios.post(delUrltype, ids).then((res) => {
          if (res.code == 200) {
            proxy.$refs["zujianname"].getData();
            state.addModal = false;
            proxy.$modal.msgSuccess(res.msg);
            store.records = [];
          }
        });
      })
      .catch(() => {
        proxy.$modal.msgWarning("删除取消");
      });
  }
}
// 动态删除行
function delchaildIndexClick(item, index) {
  if (state.tabName == "simulate") {
    console.log(item, "item");
    if (item.id) {
      axios.delete("/gas/imitate/index/" + item.id).then((res) => {
        if (res.code == 200) {
          // proxy.$refs["zujianname"].getData();
          state.formData.subIndexes.splice(index, 1);
          proxy.$modal.msgSuccess(res.msg);
        }
      });
    } else {
      state.formData.subIndexes.splice(index, 1);
    }
  } else if (state.tabName == "switch") {
    if (item.id) {
      axios.delete("/gas/switch/index/" + item.id).then((res) => {
        if (res.code == 200) {
          // proxy.$refs["zujianname"].getData();
          state.formData.subIndexes.splice(index, 1);
          proxy.$modal.msgSuccess(res.msg);
        }
      });
    } else {
      state.formData.subIndexes.splice(index, 1);
    }
  } else if (state.tabName == "accumulate") {
    if (item.id) {
      axios.delete("/gas/accumulate/index/" + item.id).then((res) => {
        if (res.code == 200) {
          // proxy.$refs["zujianname"].getData();
          state.formData.subIndexes.splice(index, 1);
          proxy.$modal.msgSuccess(res.msg);
        }
      });
    } else {
      state.formData.subIndexes.splice(index, 1);
    }
  }
}
// /** 提交按钮 */  /sensor/simulate/validParam
function submitForm() {
  let addUrltype = state.options.addUrl;
  let editUrltype = state.options.editUrl;
  //   let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    addUrltype = state.options.addUrl;
    editUrltype = state.options.editUrl;
  } else if (state.tabName == "switch") {
    addUrltype = state.options1.addUrl;
    editUrltype = state.options1.editUrl;
    //主索引
    state.switchModelList.forEach((item) => {
      //开关量模式
      if (item.value == state.formData.modeId) {
        state.formData.modeName = item.label;
      }
    });
    state.normalLogicList.forEach((item) => {
      //常态逻辑
      if (item.value == state.formData.normalLogicId) {
        state.formData.normalLogicName = item.label;
      }
    });
    //子索引
    state.formData.subIndexes.forEach((val) => {
      state.switchModelList.forEach((item) => {
        //开关量模式
        if (item.value == val.modeId) {
          val.modeName = item.label;
        }
      });
      state.normalLogicList.forEach((item) => {
        //常态逻辑
        if (item.value == val.normalLogicId) {
          val.normalLogicName = item.label;
        }
      });
    });
  } else if (state.tabName == "accumulate") {
    addUrltype = state.options2.addUrl;
    editUrltype = state.options2.editUrl;
    //主索引
    state.cumulatePeriodList.forEach((item) => {
      //累计周期
      if (item.value == state.formData.cumulatePeriodId) {
        state.formData.cumulatePeriodName = item.label;
      }
    });
    state.cumulateModeList.forEach((item) => {
      //累计模式
      if (item.value == state.formData.cumulateModeId) {
        state.formData.cumulateModeName = item.label;
      }
    });
    //子索引
    state.formData.subIndexes.forEach((val) => {
      state.cumulateModeList.forEach((item) => {
        //累计模式
        if (item.value == val.cumulateModeId) {
          val.cumulateModeName = item.label;
        }
      });
    });
  }
  let submitData = {};
  proxy.$refs["formRef"].validate((valid) => {
    if (valid) {
      submitData.hasSubIndex = state.formData.hasSubIndex == true;
      submitData.subIndexes = state.formData.subIndexes;
      // delete submitData.hasSubIndex;
      // delete submitData.subIndexes;
      submitData.primaryIndex = state.formData;
      // delete submitData.primaryIndex.subIndexes;
      // delete submitData.primaryIndex.hasSubIndex;
      console.log(submitData, "submitData");
      if (state.editId) {
        submitData.featureId = state.editId;
        axios.post(editUrltype, submitData).then((res) => {
          if (res.code == 200) {
            proxy.$refs["zujianname"].getData();
            state.addModal = false;
            proxy.$modal.msgSuccess(res.msg);
          }
        });
      } else {
        axios.post(addUrltype, submitData).then((res) => {
          if (res.code == 200) {
            proxy.$refs["zujianname"].getData();
            state.addModal = false;
            proxy.$modal.msgSuccess(res.msg);
          }
        });
      }
    }
  });
}

function cancel() {
  state.addModal = false;
}

function hasChildChange(val) {
  console.log(val, "val");
  if (val == false) {
    state.formData.subIndex = null;
  }
  if (state.tabName == "simulate") {
    if (val) {
      state.formData.subIndexes = [
        {
          indexNumber: "", //编号
          indexName: "", //子索引名称
          unit: "", //子索引单位
          lowRangeUpperLimit: "", //低量程上限
          lowRangeLowerLimit: "", //低量程下限
          highRangeUpperLimit: "", //高量程上限
          highRangeLowerLimit: "", //高量程下限
        },
      ];
    }
  } else if (state.tabName == "switch") {
    if (val) {
      state.formData.subIndexes = [
        {
          indexNumber: "", //子索引编号
          indexName: "", //子索引名称
          modeId: "", //开关量模式modeName
          normalLogicId: "", //常态逻辑normalLogicName
          highLevelDisplay: "", //高电平显示
          lowLevelDisplay: "", //低电平显示
        },
      ];
    }
  } else if (state.tabName == "accumulate") {
    if (val) {
      state.formData.subIndexes = [
        {
          indexNumber: "", //子索引编号
          indexName: "", //子索引名称
          unit: "", //单位
          cumulateModeId: "", //累计模式cumulateModeName
          initialValue: "", //起始值
          changeValue: "", //变化值
          upperLimitValue: "", //上限值
        },
      ];
    }
  }
}

function childAddClick() {
  if (state.tabName == "simulate") {
    state.formData.subIndexes.push({
      indexNumber: "", //编号
      indexName: "", //子索引名称
      unit: "", //子索引单位
      lowRangeUpperLimit: "", //低量程上限
      lowRangeLowerLimit: "", //低量程下限
      highRangeUpperLimit: "", //高量程上限
      highRangeLowerLimit: "", //高量程下限
    });
  } else if (state.tabName == "switch") {
    state.formData.subIndexes.push({
      indexNumber: "", //子索引编号
      indexName: "", //子索引名称
      modeId: "", //开关量模式modeName
      normalLogicId: "", //常态逻辑normalLogicName
      highLevelDisplay: "", //高电平显示
      lowLevelDisplay: "", //低电平显示
    });
  } else if (state.tabName == "accumulate") {
    state.formData.subIndexes.push({
      indexNumber: "", //子索引编号
      indexName: "", //子索引名称
      unit: "", //单位
      cumulateModeId: "", //累计模式cumulateModeName
      initialValue: "", //起始值
      changeValue: "", //变化值
      upperLimitValue: "", //上限值
    });
  }
}
tabChange("模拟量");

function tabChange(val) {
  state.formData = {};
  state.tabNameData = val;
  if (val == "模拟量") {
    state.optionsList = state.options;
    state.tabName = "simulate";
  } else if (val == "开关量") {
    state.optionsList = state.options1;
    state.tabName = "switch";
  } else if (val == "累计量") {
    state.optionsList = state.options2;
    state.tabName = "accumulate";
  }
  setTimeout(() => {
    getSelectList();
    proxy.$refs["zujianname"].getData();
  }, 200);
}
// state.optionsList = state.options;
function getSelectList(val) {
  axios
    .post("/gas/dict/select", ["switch_mode", "switch_normal_logic","cumulate_mode"
      ,"cumulate_period"
    ])
    .then((res) => {
      //开关量模式
      state.switchModelList = res.switch_mode.map((item) => {
        return {
          value: item.itemId,
          label: item.label,
        };
      });
      //常态逻辑
      state.normalLogicList = res.switch_normal_logic.map((item) => {
        return {
          value: item.itemId,
          label: item.label,
        };
      });
          //累计模式
    state.cumulateModeList = res.cumulate_mode.map((item) => {
        return {
          value: item.itemId,
          label: item.label,
        };
      });
    //累计周期
    state.cumulatePeriodList = res.cumulate_period.map((item) => {
        return {
          value: item.itemId,
          label: item.label,
        };
      });
    });


  // let moniArr = [];
  // let moniArr2 = [];
  // let kaiguanArr = [];
  // let kaiguanArr2 = [];
  // axios
  //   .post(state.optionsList.dataUrl, {
  //     pageNum: 1,
  //     pageSize: 999,
  //   })
  //   .then((res) => {
  //     if (res.rows) {
  //       if (state.tabNameData == "模拟量") {
  //         moniArr = res.rows.map((item) => {
  //           return { label: item.primaryIndex, value: item.primaryIndex };
  //         });
  //         moniArr = [...new Set(moniArr.map((t) => JSON.stringify(t)))].map(
  //           (s) => JSON.parse(s)
  //         );
  //         state.options.queryList.querys[1].options = moniArr;
  //         moniArr2 = res.rows.map((item) => {
  //           return { label: item.subIndex, value: item.subIndex };
  //         });
  //         moniArr2 = [...new Set(moniArr2.map((t) => JSON.stringify(t)))].map(
  //           (s) => JSON.parse(s)
  //         );
  //         state.options.queryList.querys[2].options = moniArr2;
  //       } else if (state.tabNameData == "开关量") {
  //         kaiguanArr = res.rows.map((item) => {
  //           return { label: item.primaryIndex, value: item.primaryIndex };
  //         });
  //         kaiguanArr = [
  //           ...new Set(kaiguanArr.map((t) => JSON.stringify(t))),
  //         ].map((s) => JSON.parse(s));
  //         state.options1.queryList.querys[1].options = kaiguanArr;
  //         kaiguanArr2 = res.rows.map((item) => {
  //           return { label: item.subIndex, value: item.subIndex };
  //         });
  //         kaiguanArr2 = [
  //           ...new Set(kaiguanArr2.map((t) => JSON.stringify(t))),
  //         ].map((s) => JSON.parse(s));
  //         state.options1.queryList.querys[2].options = kaiguanArr2;
  //       }
  //     }
  //   });
}
// 校验编号是否重复
const checkIndex = (val, index, arr2) => {
  let bl = true;
  let arr = JSON.parse(JSON.stringify(arr2));
  arr.splice(index, 1);
  arr.forEach((item) => {
    if (item.childIndexId == val) {
      bl = false;
    }
  });
  if (!bl) {
    ElMessage.error("编号不能重复");
    arr2[index].childIndexId = null;
  }
};
// 检验名称是否重复
const checkName = (val) => {
  let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    validParamType = state.options.validParam;
  } else if (state.tabName == "switch") {
    validParamType = state.options1.validParam;
  } else if (state.tabName == "add") {
    validParamType = state.options2.validParam;
  }
  if (state.editId) {
    axios
      .get(validParamType, {
        params: { type: 0, value: val, id: state.editId },
      })
      .then((res) => {
        if (res.code == 200) {
          state.repeat2 = false;
        }
      })
      .catch((res) => {
        state.repeat2 = true;
      });
  } else {
    axios
      .get(validParamType, { params: { type: 0, value: val } })
      .then((res) => {
        if (res.code == 200) {
          state.repeat2 = false;
        }
      })
      .catch((res) => {
        state.repeat2 = true;
      });
  }
};
// 检验主索引是否重复
const checkIndexId = (val) => {
  if (val == "") {
    return;
  }
  let validParamType = state.options.validParam;
  if (state.tabName == "simulate") {
    validParamType = state.options.validParam;
  } else if (state.tabName == "switch") {
    validParamType = state.options1.validParam;
  } else if (state.tabName == "add") {
    validParamType = state.options2.validParam;
  }
  if (state.editId) {
    axios
      .get(validParamType, {
        params: { type: 1, value: val, id: state.editId },
      })
      .then((res) => {
        if (res.code == 200) {
          state.repeat = false;
        }
      })
      .catch((res) => {
        state.repeat = true;
      });
  } else {
    axios
      .get(validParamType, { params: { type: 1, value: val } })
      .then((res) => {
        console.log(res);
        if (res.code == 200) {
          state.repeat = false;
        }
      })
      .catch((res) => {
        state.repeat = true;
      });
  }
};
</script>
<style scoped lang="scss">
.inputrange {
  background: rgba(91, 109, 128, 0.08);

  ::v-deep .el-input__wrapper {
    box-shadow: none;
    background: rgba(91, 109, 128, 0);
  }
}
.form_box {
  max-height: 580px;
  overflow: auto;
}
</style>